package com.example.mobile2032021606168xmy0427classtest2;

import android.os.Bundle;
import android.widget.Button;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {

    private TextView tvMainSub;
    private Button btnMainClick;
    private RecyclerView rvMainParking;
    private List<Parking> list=new ArrayList<>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
        initData();
        rvMainParking.setLayoutManager(new LinearLayoutManager(this));
        rvMainParking.setAdapter(new ParkingRVAdapter(list));

    }

    private void initView() {
        tvMainSub = (TextView) findViewById(R.id.tv_main_sub);
        btnMainClick = (Button) findViewById(R.id.btn_main_click);
        rvMainParking = (RecyclerView) findViewById(R.id.rv_main_parking);
    }
    private  void initData(){
        list.add(new Parking("星湖城停车场","距离：12公里",12,"地址：汕头市龙湖区金砂路","价格：5元/时","更多信息"));
        list.add(new Parking("小公园停车场","距离：40公里",12,"地址：汕头市金平区","7元/时","更多信息"));
        list.add(new Parking("帝豪酒店停车场","距离：18公里",12,"地址：汕头市龙湖区","6元/时","更多信息"));
        list.add(new Parking("十一合艺术村停车场","距离：2公里",12,"地址：汕头市龙湖区新海街","5元/时","更多信息"));
        list.add(new Parking("合胜百货停车场","距离：22公里",12,"地址：汕头市龙湖区衡山路","6元/时","更多信息"));
    }
}